#include <cstdio>

using namespace std; 

#define N 26

struct node_s {
	node_s *left, *right, *parent; 
	char c; 
}; 

struct node_s node[N]; 

void link(char parent, char left, char right)
{
	node_s *pp=&node[(int)(parent-'a')]; 
	node_s *lp=(left=='*' ? NULL : &node[(int)(left-'a')]); 
	node_s *rp=(right=='*' ? NULL : &node[(int)(right-'a')]); 
	pp->left = lp; 
	pp->right = rp; 
	if (rp) {
		rp->parent = pp; 
	}
	if (lp) {
		lp->parent = pp; 
	}
}

void output(node_s *root)
{
	printf("%c", root->c); 
	if (root->left) 
		output(root->left); 
	if (root->right) 
		output(root->right); 
}

int main()
{
	node_s *p; 
	int n, i; 
	char s[10]; 
	
	//freopen("p1305.in", "r", stdin); 
	
	for (i=0; i<N; i++) {
		p = &node[i]; 
		p->left = NULL; 
		p->right = NULL; 
		p->parent = NULL; 
		p->c = 'a' + i; 
	}
	
	scanf("%d\n", &n); 
	//printf("n=%d\n", n); 
	for (i=0; i<n; i++) {
		scanf("%s\n", s); 
		//printf("s=[%s]\n", s); 
		link(s[0], s[1], s[2]); 
	}
	
	for (i=0; i<N; i++) {
		p = &node[i]; 
		if (p->parent==NULL && (p->left || p->right)) {
			break; 
		}
	}
	output(p); 
	printf("\n"); 
	return 0; 
}


